#include "stdafx.h"
#include "CppUnitTest.h"

#include "../Geometry/Vector3d.h"
#include "../Geometry/Vector3d.cpp"
using Geometry::Vector3d;

using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace GeometryTests
  {
  TEST_CLASS(UnitTestVector3d)
    {
    public:

      TEST_METHOD(ShouldIndexCorrect)
        {
        Vector3d v(1.0, 2.0, 3.0);
        Assert::AreEqual(1.0, v[0]);
        Assert::AreEqual(2.0, v[1]);
        Assert::AreEqual(3.0, v[2]);
        Assert::ExpectException<std::exception>([&v](){double val = v[3]; });
        }

      TEST_METHOD(ShouldAddCorrect)
        {
        Vector3d v1(1, -2, 3);
        Vector3d v2(-3, 2, -1);
        Vector3d v3 = v1 + v2;
        Assert::AreEqual(-2.0, v3[0]);
        Assert::AreEqual(0.0, v3[1]);
        Assert::AreEqual(2.0, v3[2]);
        }

      TEST_METHOD(ShouldSubtractCorrect)
        {
        Vector3d v1(1, -2, 3);
        Vector3d v2(-3, 2, -1);
        Vector3d v3 = v1 - v2;
        Assert::AreEqual(4.0, v3[0]);
        Assert::AreEqual(-4.0, v3[1]);
        Assert::AreEqual(4.0, v3[2]);
        }

      TEST_METHOD(ShouldDotProductCorrect)
        {
        Vector3d v1(1, -2, 3);
        Vector3d v2(-3, 2, -1);
        double actual = v1 * v2;
        double expected = -10.0;
        Assert::AreEqual(expected, actual);
        }

      TEST_METHOD(ShouldVectorProductCorrect)
        {
        Vector3d v1(1, -2, 3);
        Vector3d v2(-3, 2, -1);
        Vector3d res = v1 ^ v2;
        
        double expected_x = -4.0;
        double expected_y = -8.0;
        double expected_z = -4.0;

        Assert::AreEqual(res[0], expected_x);
        Assert::AreEqual(res[1], expected_y);
        Assert::AreEqual(res[2], expected_z);

        }

      TEST_METHOD(ShouldCompareCorrectly)
        {
        Vector3d v1(1, -2, 0);
        Vector3d v2(1, -2, 0);
        Vector3d v3(1, 2, 0);

        Assert::IsTrue(v1 == v2);
        Assert::IsFalse(v1 == v3);
        Assert::IsFalse(v2 == v3);
        }



    };
  }